home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group03a.txt
/
000034_icon-group-sender_Wed Mar 12 12:50:02 2003.msg
< prev
next >
Wrap
Internet Message Format
|
2003-12-22
|
2KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id h2CJmd603887
for icon-group-addresses; Wed, 12 Mar 2003 12:48:39 -0700 (MST)
Message-Id: <200303121948.h2CJmd603887@baskerville.CS.Arizona.EDU>
X-Authentication-Warning: weaver.tuc.noao.edu: swampler set sender to swampler@noao.edu using -f
Subject: Re: Sorting lists
From: Steve Wampler <swampler@noao.edu>
To: rjhare@ed.ac.uk
Cc: icon-group@cs.arizona.edu
Date: 12 Mar 2003 09:34:29 -0700
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
On Wed, 2003-03-12 at 08:51, Steve Wampler wrote:
> On Wed, 2003-03-12 at 07:21, rjhare@ed.ac.uk wrote:
> > I don't have the book to hand and am sitting in an Icon-free zone at
> > the moment. What do I get if I sort a list of lists like this:
> >
> > [ [b,c], [a,d] ]
> >
> > I hope I get:
> >
> > [ [a,d], [b,c]]
> >
> > but fear that I might get:
> >
> > [ a, b, c, d]
> >
> > Thanks.
> >
> > Roger Hare
>
> To make sure I understand, you have (say)
>
> a := [ ["b","c"], ["a","d"] ]
>
> and want to know the result of sort(a), right?
>
> The answer is that you won't get [ "a", "b", "c", "d" ],
> but you probably will not get [ ["a","d"], ["b", "c"] ], either.
>
> When sorting a list of structures (what you have), the
> sorting order is by time of creation of those structures.
>
> Icon won't look 'inside' those structures to see what they
> contain. So, since ["b","c"] was created before ["a","d"]
> in the above example, I would expect the result of the
> sort to be [ ["b","c"], ["a","d"] ].
A quick followup...
If you do have a list of lists of strings, you *can* use
sortf(X,i) instead of sort() to sort by the first element in
each of the sublists, so:
b := sortf(a, 1)
would do what you want in the above example.
--
Steve Wampler <swampler@noao.edu>
National Solar Observatory